﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Enums;
using RoadTeam.Model;
using RoadTeam.SysInterface;

namespace RoadTeam.BLL
{
    public class CsValidateRoomInfoBLL
    {
        public static DataTable GetEmptyTable()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new Model.CsValidateRoomInfo() { ValidateRInfoIdentifier = "-1" };
            return CsValidateRoomInfo.Select(where, GlobalConfig.ConnectionString);
        }

        public void insert(DataTable dt_ValidateRoomInfo)
        {
            //插入对接系统

            DataTable dt_vrInfo = FactoryClass.CreateCsValidateRoomInfo().GetEmptyTable();
            DataRow dr_vrInfo;

 //           ValidateRoomID,RoomTypeID,ValidateObjectID,ValidateProID,ValidateState,
 //ValidateExplain,IsRepair,FillStaffID,FillDate,RepairBeginDate,RepairEndDate,App_Identifier
            foreach (DataRow dr in dt_ValidateRoomInfo.Rows)
            {
                dr_vrInfo = dt_vrInfo.NewRow();
                dr_vrInfo[0] = FactoryClass.CreateCsValidateRoom().GetValidateRoomID(dr["ValidateRoomIdentifier"].ToString());
                dr_vrInfo[1] = FactoryClass.CreateCsRoomType().GetRoomTypeID(dr["RoomTypeIdentifier"].ToString());
                dr_vrInfo[2] = FactoryClass.CreateCsValidateObject().GetValidateObjectID(dr["ValidateObjectIdentifier"].ToString());
                dr_vrInfo[3] = FactoryClass.CreateCsValidatePro().GetCsValidateProID(dr["ValidateProIdentifier"].ToString());
                dr_vrInfo[4] = dr["ValidateState"];
                dr_vrInfo[5] = dr["ValidateExplain"];
                dr_vrInfo[6] = dr["IsRepair"];
                dr_vrInfo[7] = FactoryClass.CreateSmStaff().GetStaffID(dr["FillStaffIdentifier"].ToString()) ;
                dr_vrInfo[8] = dr["FillDate"];
                dr_vrInfo[9] = dr["RepairBeginDate"];
                dr_vrInfo[10] = dr["RepairEndDate"];
                dr_vrInfo[11] = dr["ValidateRInfoIdentifier"].ToString();
                dt_vrInfo.Rows.Add(dr_vrInfo);
            }

            FactoryClass.CreateCsValidateRoomInfo().Insert(dt_vrInfo);

            CsValidateRoomInfo.InsertDatatable(dt_ValidateRoomInfo, GlobalConfig.ConnectionString);
        }
    }
}
